listen			= ../listen
utility 		= ../utility
handler_poll 	= ../handler_poll
handler 		= ../handler
oj				= ../oj
task			= ../task
proxy			= ../proxy
deserialize		= ../deserialize
serialize	 	= ../serialize 
html_parser		= ../html_parser
buff			= ../buff

CFLAGS 			= -Wno-deprecated -I$(utility) -I$(buff) -I$(handler_poll) \
				  -I$(handler) -I$(oj) -I$(task) -I$(deserialize) \
				  -I$(proxy) -I$(html_parser) -I$(listen) -I$(serialize)
LIBS 			= -lpthread -lcurl -lrt -lpython2.7

GVJ				= $(utility)/gvj.cpp

POJ				= $(oj)/poj.cpp
POJ_HANDLER		= $(handler)/poj_handler.cpp
POJ_DES			= $(deserialize)/poj_deserialize.cpp
POJ_PROXY 		= $(proxy)/poj_proxy_process.cpp
POJ_PARSER		= $(html_parser)/poj_parser.cpp

HDU				= $(oj)/hdu.cpp
HDU_HANDLER		= $(handler)/hdu_handler.cpp
HDU_PROXY		= $(proxy)/hdu_proxy_process.cpp
HDU_DES			= $(deserialize)/hdu_deserialize.cpp
HDU_PARSER		= $(html_parser)/hdu_parser.cpp


SOCKET_RECV_BUFF= $(buff)/socket_recv_buff.cpp
SOCKET_SEND_BUFF= $(buff)/socket_send_buff.cpp
PIPE_RECV_BUFF	= $(buff)/pipe_recv_buff.cpp
PIPE_SEND_BUFF	= $(buff)/pipe_send_buff.cpp
LISTEN_DES		= $(deserialize)/listen_deserialize.cpp

ALL_OBJ 		= main.o proxy_starter.o poj.o poj_handler.o poj_proxy_process.o \
				  pipe_recv_buff.o pipe_send_buff.o socket_recv_buff.o socket_send_buff.o\
				  gvj.o gvj_server.o poj_parser.o\
				  listen_deserialize.o \
				  hdu_proxy_process.o hdu_handler.o request_filter.o \
				  hdu.o hdu_parser.o


gvj: $(ALL_OBJ)
	g++ $(ALL_OBJ) -o gvj $(CFLAGS) $(LIBS)
	make clean

main.o: main.cpp
	g++ -c main.cpp -o main.o $(CFLAGS)
gvj_server.o: gvj_server.cpp
	g++ -c gvj_server.cpp -o gvj_server.o $(CFLAGS)

request_filter.o: request_filter.cpp
	g++ -c request_filter.cpp -o request_filter.o $(CFLAGS)

socket_recv_buff.o: $(SOCKET_RECV_BUFF)
	g++ -c $(SOCKET_RECV_BUFF) -o socket_recv_buff.o $(CFLAGS)
socket_send_buff.o: $(SOCKET_SEND_BUFF)
	g++ -c $(SOCKET_SEND_BUFF) -o socket_send_buff.o $(CFLAGS)
pipe_recv_buff.o: $(PIPE_RECV_BUFF)
	g++ -c $(PIPE_RECV_BUFF) -o pipe_recv_buff.o $(CFLAGS)
pipe_send_buff.o: $(PIPE_SEND_BUFF)
	g++ -c $(PIPE_SEND_BUFF) -o pipe_send_buff.o $(CFLAGS)

listen_deserialize.o: $(LISTEN_DES)
	g++ -c $(LISTEN_DES) -o listen_deserialize.o $(CFLAGS)

poj.o: $(POJ)
	g++ -c $(POJ) -o poj.o $(CFLAGS)
poj_parser.o: $(POJ_PARSER)
	g++ -c $(POJ_PARSER) -o poj_parser.o $(CFLAGS)
poj_handler.o: $(POJ_HANDLER)
	g++ -c $(POJ_HANDLER) -o poj_handler.o $(CFLAGS)
proxy_starter.o: proxy_starter.cpp
	g++ -c proxy_starter.cpp -o proxy_starter.o $(CFLAGS) 

hdu.o: $(HDU)
	g++ -c $(HDU) -o hdu.o $(CFLAGS)
hdu_task.o: $(HDU_TASK)
	g++ -c $(HDU_TASK) -o hdu_task.o $(CFLAGS)
hdu_parser.o: $(HDU_PARSER)
	g++ -c $(HDU_PARSER) -o hdu_parser.o $(CFLAGS)
hdu_handler.o: $(HDU_HANDLER)
	g++ -c $(HDU_HANDLER) -o hdu_handler.o $(CFLAGS)

poj_proxy_process.o: $(POJ_PROXY)
	g++ -c $(POJ_PROXY) -o poj_proxy_process.o $(CFLAGS)
hdu_proxy_process.o: $(HDU_PROXY)
	g++ -c $(HDU_PROXY) -o hdu_proxy_process.o $(CFLAGS)


gvj.o: $(GVJ)
	g++ -c $(GVJ) -o gvj.o $(CFLAGS)
conf_loader.o: conf_loader.cpp
	g++ -c conf_loader.cpp -o conf_loader $(CFLAG)

clean:
	rm -v *.o
